In this step you create a text layer in Kanzi Studio and an alias pointing to that text layer, then in the C application you set the value of the property that defines the content shown by the text layer in your Kanzi application.




/* Include required headers */ /* Base structure for scene graph nodes. */ #include <user/scene_graph/kzu_object.h> /* Text layer class. */ #include <user/layers/kzu_text_layer.h> /* Layer base class. */ #include <user/layers/kzu_layer.h> /* Fixed property types. */ #include <user/properties/kzu_fixed_properties.h>
KZ_CALLBACK static kzsError setProperty(struct KzaApplication* application)
{
kzsError result;
/* Gets root layer from the scene graph. */
struct KzuLayer* rootLayer = kzaApplicationGetRootLayer(application);
/* Gets the alias that points to the text layer in the scene graph. */
/* Use the same name you used for the alias in the Kanzi Studio project. */
/* For example, this tutorial uses name TextLayer. */
struct KzuObjectNode* textLayer = kzuObjectNodeGetRelative(kzuLayerToObjectNode(rootLayer), "#TextLayer");
/* Sets the property value of the text layer's Text property. */
result = kzuObjectNodeSetStringProperty(textLayer, KZU_PROPERTY_TYPE_TEXT_LAYER__TEXT, "Hello world!");
kzsErrorForward(result);
kzsSuccess();
}/* Calls the setProperty function when the project is loaded. */ configuration->onProjectLoaded = setProperty;


This is what your hello_world.c looks like when you complete this step.
#include <application/kza_application_interface.h>
#include <application/kza_application.h>
/* Include required headers. */
/* Core logging */
#include <core/debug/kzc_log.h>
/* Base structure for scene graph nodes */
#include <user/scene_graph/kzu_object.h>
/* Text layer class */
#include <user/layers/kzu_text_layer.h>
/* Layer base class */
#include <user/layers/kzu_layer.h>
/* Fixed property types */
#include <user/properties/kzu_fixed_properties.h>
KZ_CALLBACK static kzsError keyInputEventHandler(struct KzaApplication*
application, const struct KzsInputEventKey* inputData)
{
enum KzsInputKey button = kzsInputEventKeyGetButton(inputData);
/* Handle the escape or Q button to exit the application. */
if (button == KZS_KEY_ESC || button == KZS_KEY_Q)
{
kzaApplicationQuit(application);
}
kzsSuccess();
}
KZ_CALLBACK static kzsError writeToLog(struct KzaApplication* application)
{
kzsLog(KZS_LOG_LEVEL_INFO, "Hello world!");
kzsSuccess();
}
KZ_CALLBACK static kzsError setProperty(struct KzaApplication* application)
{
kzsError result;
/* Gets root layer from the scene graph. */
struct KzuLayer* rootLayer = kzaApplicationGetRootLayer(application);
/* Gets the alias that points to the text layer in the scene graph. */
/* Use the same name you used for the alias in the Kanzi Studio project. */
/* For example, this tutorial uses name TextLayer. */
struct KzuObjectNode* textLayer = kzuObjectNodeGetRelative(kzuLayerToObjectNode(rootLayer), "#TextLayer");
// Sets the property value of the text layer's Text property
result = kzuObjectNodeSetStringProperty(textLayer, KZU_PROPERTY_TYPE_TEXT_LAYER__TEXT, "Hello world!");
kzsErrorForward(result);
kzsSuccess();
}
KZ_CALLBACK void kzApplicationConfigure(const struct KzaSystemProperties*
systemProperties, struct KzaApplicationProperties* configuration)
{
configuration->memoryPoolSize = 20 * 1024 * 1024;
configuration->binaryName = "Hello_World.kzb.cfg";
configuration->onKeyInputEvent = keyInputEventHandler;
/* Calls the writeToLog function when the project is loaded. */
configuration->onProjectLoaded = writeToLog;
/* Calls the setProperty function when the project is loaded. */
configuration->onProjectLoaded = setProperty;
}
In this tutorial you learned how to create a Kanzi Studio project with C application and edited a property of an object you created in Kanzi Studio. Now you can complete a more advanced Kanzi programming tutorial. See Dynamic object generator.
To find out more about what you can create using the Kanzi Engine API, see API reference
To find out more about using aliases, see Aliases.
To learn more about creating Kanzi applications, see Tutorials.
To find out more about Kanzi Studio features, see Working with ....